﻿using MediatR;
using SheepStorage.API.Application.Command.BuildingManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.BuildingManagementCommandHandler
{
    public class BuildingManagementDelRangeCommandHandler : IRequestHandler<BuildingManagementDelRangeCommand, Results<int>>
    {

        private readonly IBuildingManagementService buildingManagementService;

        public BuildingManagementDelRangeCommandHandler(IBuildingManagementService buildingManagementService)
        {
            this.buildingManagementService = buildingManagementService;
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(BuildingManagementDelRangeCommand request, CancellationToken cancellationToken)
        {
            var list = buildingManagementService.DelRangeBuildingManagement(request.BuildingManagementIds);
            return Results<int>.DataResult(list);   
        }
    }
}
